<?php
include('../../inc/global.inc');
include("../islogin.php");
$url="index_3.php";
$thepage=$_GET['page']?$_GET['page']:1;
$maxpage=20;
?>
<?php
//删除信息
if($_GET['del_act']){
$urls=$_SERVER['HTTP_REFERER'];
  //数据处理
  $d_rs=@mysql_query("select * from buy where id='".$_GET['del_id']."'");
  $d_row=@mysql_fetch_array($d_rs);
  if($d_row[catalog_id1]){
       $c_rs=@mysql_query("select * from catalog where id='$d_row[catalog_id1]'");
	   $c_row=@mysql_fetch_array($c_rs);
	   $b_num=$c_row[b_num]-1;
	   mysql_query("update catalog set b_num='$b_num' where id='$c_row[id]'");
  }
  if($d_row[catalog_id2]){
       $c_rs=@mysql_query("select * from catalog where id='$d_row[catalog_id2]'");
	   $c_row=@mysql_fetch_array($c_rs);
	   $b_num=$c_row[b_num]-1;
	   mysql_query("update catalog set b_num='$b_num' where id='$c_row[id]'");
  }  
 if($d_row[catalog_id3]){
       $c_rs=@mysql_query("select * from catalog where id='$d_row[catalog_id3]'");
	   $c_row=@mysql_fetch_array($c_rs);
	   $b_num=$c_row[b_num]-1;
	   mysql_query("update catalog set b_num='$b_num' where id='$c_row[id]'");
  } 
mysql_query("delete from buy where id='".$_GET['del_id']."'");
echo "<script>location='".$urls."';</script>";
}
?>
<HTML>
<HEAD>
<TITLE>Admin</TITLE>
<META http-equiv=Content-Type content="text/html; charset=utf-8">
<LINK href="../css/css.css" rel=stylesheet>
<script type='text/javascript' src="../js/islogin.js" charset="gb2312"></script>
</HEAD>
<BODY>
<center>
  <table width="95%" border="0" cellpadding="0" cellspacing="1" bgcolor="#000000">
    <tr>
      <td height="25" bgcolor="#EEEEF9" style="padding-left:5px;">未通过Buy信息&nbsp;&nbsp;<a href="javascript:history.go(-1)">返回</a></td>
    </tr>
  </table>
  <table width="95%" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td height="5"></td>
    </tr>
  </table>
<table width="95%" border="0" cellpadding="0" cellspacing="1" bgcolor="#000000">
    <tr>
      <td width="6%" height="30" align="center" bgcolor="#8DA8CF">编号</td>
      <td width="31%" align="center" bgcolor="#8DA8CF">产品名称</td>
      <td width="16%" align="center" bgcolor="#8DA8CF">会员账号</td>
      <td width="15%" align="center" bgcolor="#8DA8CF">城市</td>
      <td width="21%" align="center" bgcolor="#8DA8CF">发布时间</td>
      <td width="9%" align="center" bgcolor="#8DA8CF">管理</td>
    </tr>
<?php
$sql="select buy.id,buy.member_id,buy.b_title,buy.b_addtime,member.m_user,member.city from buy inner join member on (buy.member_id=member.id) where b_cl=1 and b_sh=0 order by id desc limit ".($thepage-1)*$maxpage.",$maxpage";

$rs=mysql_query($sql);
$i=1;
while($row=mysql_fetch_array($rs)){
$color=($i%2)?"#FFFFFF":"#eeeeee";
?>
    <tr bgcolor=<?=$color?>>
      <td height="25" align="center"><?=$i?></td>
	  <td align="left" style="padding-left:5px;"><?=$row[b_title]?></td>
	  <td align="center"><?=$row['m_user']?></td>
	  <td align="center"><?=$row['city']?></td>
	  <td align="center"><?=$row[b_addtime]?></td>
	  <td align="center"><a href="index_modify.php?xg_id=<?=$row['id']?>">编辑</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href="<?=$url?>?del_act=ok&del_id=<?=$row['id']?>" onClick="return del()">删除</a></td>
    </tr>
<?php
$i++;}
//分页参数
$totalrecord=mysql_num_rows(mysql_query("select * from buy where b_sh=0 and b_cl=1 "));
$totalpage=ceil($totalrecord/$maxpage);
?>
<tr><form method="get" action="<?=$url?>">
   <td height="25" colspan="6" align="center" bgcolor="#FFFFFF">
<?php if($thepage>1){?>
   <a href="<?=$url?>">第一页</a>&nbsp;<a href="<?=$url?>?page=<?=$thepage-1?>">上一页</a>&nbsp;
<?php }?>  
<?php if($thepage!=$totalpage&&$totalpage>0){?>
   <a href="<?=$url?>?page=<?=$thepage+1?>">下一页</a>&nbsp;<a href="<?=$url?>?page=<?=$totalpage?>">最后一页</a>&nbsp;
<?php }?>   
   【共<font color="red"><?=$totalrecord?></font>条记录】【每页<font color="red"><?=$maxpage?></font>条记录】【共<font color="red"><?=$totalpage?></font>页】<input type="text" name="page" size="3" onKeyUp="IsDigit(this);">&nbsp;<input type="submit" value="GO"></td></form>
</tr>
  </table>
</center>
</BODY>
</HTML>

<script language="javascript">
function IsDigit(obj) 
{ 
if(obj.value.replace(/[\d+]/ig,"").length>0) { 
  alert('enter an number'); 
  document.getElementById(obj).value =""; 
} 
} 
</script>